package org.handwerkszeug.tournament.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.handwerkszeug.tournament.Game;
import org.handwerkszeug.tournament.Player;

public class DefaultGame implements Game {

	protected Set<Player> players;

	protected List<Player> order;

	public DefaultGame(Set<Player> players) {
		assert players != null;
		this.players = players;
		this.order = new ArrayList<Player>(players.size());
		for (Player p : players) {
			p.playWith(this);
		}
	}

	@Override
	public Set<Player> players() {
		return this.players;
	}

	@Override
	public void order(Player p, int rank) {
		assert order.size() < players.size();
		this.order.add(p);
	}

	@Override
	public void assignMatchPoints() {
		switch (this.players.size()) {
		case 4: {
			// 1 1 1 1
			// 1 1 1 4
			// 1 1 3 4
			// 1 2 3 4
			// 1 2 2 4
			// 1 2 2 2
			// 1 2 3 3
			break;
		}
		case 3: {
			// 1 1 1
			// 1 1 3
			// 1 2 3
			// 1 2 2
			break;
		}
		case 2: {
			// 2人卓を考慮しない。
		}
		default: {
			throw new IllegalStateException();
		}
		}
	}
}
